﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Microsoft Corp." file="SqlAzureManagementTestWebRequestCreate.cs">
//   All rights reserved. See License.txt in the project root for license information.
// </copyright>
// 
// --------------------------------------------------------------------------------------------------------------------
namespace AzureManagementTests.TestSupport
{
    using System;
    using System.Collections.Generic;
    using System.Net;

    public class SqlAzureManagementTestWebRequestCreate : IWebRequestCreate
    {
        private TestSqlAzureManagementWebResponseFactory factory;

        public string BaseUri { get; set; }

        public string ApiVersion { get; set; }

        public string SubscriptionId { get; set; }

        public IList<string> ManagementCertificates { get; set; }

        public IList<SqlAzureServerMock> Servers { get; set; }

        public WebRequest Create(Uri uri)
        {
            if (this.factory == null)
            {
                this.factory = new TestSqlAzureManagementWebResponseFactory
                                   {
                                       BaseUri = this.BaseUri, 
                                       ApiVersion = this.ApiVersion, 
                                       SubscriptionId = this.SubscriptionId, 
                                       ManagementCertificates =
                                           this.ManagementCertificates, 
                                       Servers = this.Servers
                                   };
            }

            return new TestWebRequest(uri, this.factory);
        }
    }
}